#include <stdio.h>
#include <signal.h>
#include <unistd.h>

int main() {
	printf("parent process running......\n");
	pid_t fpid1, fpid2;
	fpid1 = fork();

	if (fpid1 < 0) {
		printf("Error in fork!\n");
	} else if (fpid1 == 0) {
		printf("This is child process 1, pid=%d\n", getpid());
	} else {
		printf("parent process running......\n");
		fpid2 = fork();
		if(fpid2 < 0) {
			printf("Error in fork!\n");
		} else if(fpid2 == 0) {
			printf("This is child process 2, pid=%d\n",getpid());
		}
	}
	sleep(1);
	printf("child process 1 killed by parent process\n");
	kill(fpid1,SIGINT);
	printf("child process 2 killed by parent provess\n");
	kill(fpid2,SIGINT);
	printf("parent process end\n");

return 0;
}
